package com.demo.controller;


import cn.hutool.core.collection.CollUtil;
import com.demo.entity.Student;
import com.demo.service.IMGService;
import org.bson.Document;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


@RequestMapping("MGDemo")
@RestController
public class MongodbDemo {

    @Resource
    private IMGService imgService;

    @PostMapping("insertOne")
    public int insertOne(){
        return imgService.insertMGOne();
    }

    @PostMapping("insertStudent")
    public int insertStudent(@RequestBody Student student){
        return imgService.insertStudent(student);
    }

    @PostMapping("insertListStudent")
    public int insertListStudent( @RequestBody  List<Student> students){
        return imgService.insertListStudent(students);
    }

    @PostMapping("insertManyData")
    public int insertManyData(){
        return imgService.insertManyData();
    }

    @GetMapping("selectOne")
    public Document selectOne(){
        return imgService.selectOne();
    }

    @GetMapping("selectAll")
    public List selectAll(){
        return imgService.selectAll();
    }

    @GetMapping("selectByName")
    public List selectByName(String name){
        return imgService.selectByName(name);
    }

    @PostMapping("updateByName")
    public int updateByName(String name , String phone){
        return imgService.updateByName(name , phone);
    }

    @DeleteMapping("deleteByName")
    public int deleteByName(String name){
        return imgService.deleteByName(name);
    }
}
